package com.example.demotest.pojo.dto;

import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.NotBlank;
//ProductDto 用于 接收用户通过前端提交的商品信息,比如添加新商品或更新商品信息时的请求体（JSON 对象）。系统在接收到这些请求后，会将其转换为 ProductDto 实例，并自动触发字段校验
public class ProductDto{
    private Integer productID;

    public Integer getProductID() {
        return productID;
    }

    public void setProductID(Integer productID) {
        this.productID = productID;
    }
    //用于校验字符串不能为空或全是空白符，如果为空则抛出 "商品名不能为空" 错误
    @NotBlank(message = "商品名不能为空")
    private String productName;
    //商品价格，必须大于等于 0.01
    //@DecimalMin 用于校验最小值
    @DecimalMin(value = "0.01", message = "价格必须大于0")
    private Double productPrice;

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    private String description;

    private Integer viewCount = 0;

    public Integer getViewCount() {
        return viewCount;
    }

    public void setViewCount(Integer viewCount) {
        this.viewCount = viewCount;
    }

    public @NotBlank(message = "商品名不能为空") String getProductName() {
        return productName;
    }

    public void setProductName(@NotBlank(message = "商品名不能为空") String productName) {
        this.productName = productName;
    }

    @Override
    public String toString() {
        return "ProductDto{" +
                "productID=" + productID +
                ", productName='" + productName + '\'' +
                ", productPrice=" + productPrice +
                '}';
    }

    public @DecimalMin(value = "0.01", message = "价格必须大于0") Double getProductPrice() {
        return productPrice;
    }

    public void setProductPrice(@DecimalMin(value = "0.01", message = "价格必须大于0") Double productPrice) {
        this.productPrice = productPrice;
    }
}
